package cn.edu.gdpt.mobile213.mobile2121606097wjc0514;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class ShoppingActivity extends AppCompatActivity {
    private TextView tvShoppingSupplier;
    private Button btnShoppingTitle;
    private Button btnShoppingConfirm;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_shopping);
        initView();
        btnShoppingTitle.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent=new Intent(ShoppingActivity.this,MainActivity.class);
                startActivityForResult(intent,1);
            }
        });
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, @NonNull Intent data){
        super.onActivityResult(requestCode,resultCode,data);
        if (requestCode==1&&resultCode==RESULT_OK){
            tvShoppingSupplier.setText(data.getStringExtra("carParts"));
        }
    }

    private void initView() {
        tvShoppingSupplier=(TextView) findViewById(R.id.tvShoppingSupplier);
        btnShoppingTitle=(Button) findViewById(R.id.btnShoppingTitle);
        btnShoppingConfirm=(Button) findViewById(R.id.btnShoppingConfirm);
    }
}